<?php

/**
 * @author      :   QuangLT
 * @name        :   Thethao_Business_Block
 * @copyright   :   Fpt Online
 * @todo        :   Block business
 */
class Fpt_Business_Block
{

    /**
     * Parent instance
     * @var <object>
     */
    private $_modelParent = null;

    /**
     *
     * @var <type>
     */
    protected static $instances = null;

    /**
     * Constructor of class
     * we don't permit an explicit call of the constructor! (like $v = new Singleton())
     */
    protected function __construct()
    {
        //nothing
    }

    /**
     * Get instance of class
     *
     * @param string $className
     * @return object
     */
    public final static function getInstance($options = array())
    {
        //Check class name
        $className = $options['adapter'] ;
        //If empty className
        if(empty($className))
        {
            return Fpt_Server::setOutputData(-1,'empty class name', null);
        }

        //Switch to get classname
        switch(strtolower($className))
        {
            case 'mysql':
                $className = 'Fpt_Business_Block_Adapter_Mysql';
                break;
            case 'redis':
                $className = 'Fpt_Business_Block_Adapter_Redis';
                break;
            default:
                //throw new Fpt_Business_Exception("No instance of class $className");
                break;
        }

        //Put to list
        if(!isset(self::$instances[$className]))
        {
            self::$instances[$className] = $className::getInstance();
        }

        //Return object class
        return self::$instances[$className];
    }

//    /**
//     * get block list
//     * @param type $arrParams
//     * @return type 
//     */
//    public function getBlockList($arrParams)
//    {
//        return $this->_modelParent->getBlockList($arrParams);
//    }
//
//    /**
//     * get block detail
//     * @param type $arrParams
//     * @return type 
//     */
//    public function getBlockDetail($arrParams)
//    {
//        return $this->_modelParent->getBlockDetail($arrParams);
//    }

}

